<template>
  <div>
    <!-- 分页列表 -->
    <table-box
      ref="shopRebateTable"
      :table-config="tableConfig"
      :dragable="true"
      :off-set="-20"
      :other-filters="otherFilter"
      :selected-arry.sync="tableSelected"
      click-row-selection
      show-index
      show-selection
      no-request
      @data-change="dataChange"
      @selection-change="selectionChange"
      @btnOperate="btnOperate"
    />
    <export-files v-if="exportVisible" title="导出" :config="exportAllConfig" :visible.sync="exportVisible" @success="handleExportSuccess" />
  </div>
</template>

<script>
export default {
  Name: 'ShopRebate',
  props: {
    detailData: {
      type: [String, Object],
      default: ''
    }
  },
  data() {
    return {
      exportVisible: false,
      otherFilter: [],
      tableSelected: [],
      // 门店返利详情
      tableConfig: {
        interfacePath: `${process.env.VUE_APP_BASE_API}/api/v1/shopRebate/page`,
        hideSearchBar: true,
        pageSize: 20,
        sort: 'rebateApplyCode',
        order: 'desc',
        setting: [
          {
            prop: 'rebateApplyCode',
            label: '返利申请单号',
            minWidth: 150
          },
          {
            prop: 'schedule',
            label: '返利进度',
            minWidth: 150,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'SCHEDULE'
            }
          },
          {
            prop: 'acceptHardcoverTaskCode',
            label: '硬装验收任务',
            minWidth: 130
          },
          {
            prop: 'hardAcceptSchedule',
            label: '硬装验收进度',
            minWidth: 170,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'DECORATION_SCHEDULE'
            }
          },
          {
            prop: 'acceptSoftwearTaskCode',
            label: '软装验收任务',
            minWidth: 170
          },
          {
            prop: 'softAcceptSchedule',
            label: '软装验收进度',
            minWidth: 170,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'DECORATION_SCHEDULE'
            }
          },
          {
            prop: 'reportApplyTime',
            label: '设计申请时间',
            minWidth: 170
          },
          {
            prop: 'acceptWholeTotalArea',
            label: '验收整装总面积',
            minWidth: 170
          },
          {
            prop: 'acceptSimpleTotalArea',
            label: '验收简装总面积',
            minWidth: 170
          },
          {
            prop: 'dheadAccounting', // shopAccounting
            label: '返利核算',
            minWidth: 170
          },
          {
            prop: 'isMonthReturn',
            label: '是否涉及月返',
            minWidth: 170,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'BOOLEANS'
            }
          },
          {
            prop: 'firstStartTime',
            label: '首返时间',
            minWidth: 170
          },
          {
            prop: 'monthStartTime',
            label: '月返开始时间',
            minWidth: 170
          },
          {
            prop: 'expectMonthEndTime',
            label: '预计月返结束时间',
            minWidth: 170
          },
          {
            prop: 'isRebate',
            label: '返利是否结束',
            minWidth: 170,
            propEnum: {
              domainCode: 'marketing',
              appCode: 'slm',
              dictTypeCode: 'BOOLEANS'
            }
          },
          {
            prop: 'actualEndTime',
            label: '实际返利结束时间',
            minWidth: 170
          }
          // {
          //   prop: 'isFullAmountDraw',
          //   label: '是否全额提完返利',
          //   minWidth: 170,
          //   propEnum: {
          //     domainCode: 'marketing',
          //     appCode: 'slm',
          //     dictTypeCode: 'BOOLEANS'
          //   }
          // }
        ],
        btnList: [
          {
            buttonName: '导出',
            optCode: 'export',
            outerFlag: true
          }]
      }
    }
  },
  computed: {
    exportAllConfig() {
      return [{
        code: 'export',
        name: '门店返利',
        dataApi: '/slm-admin/api/v1/shopRebate/export?type=0',
        selectedRows: this.tableSelected,
        paramsRaw: {},
        filtersRaw: this.otherFilter,
        queryField: 'id'
      }]
    }
  },
  created() {
    this.constCode = this.detailData.constCode
    this.otherFilter = [{ 'id': 'constCode', 'property': 'constCode', 'operator': '=', 'value': this.constCode }]
    this.$nextTick(() => {
      this.$refs.shopRebateTable.initTableData()
    })
  },
  activated() {},
  methods: {
    btnOperate(flag) {
      switch (flag) {
        case 'export':
          this.exportVisible = true
          break
        default:
          break
      }
    },
    selectionChange(rows) {
      this.tableSelected = rows
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
